
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context;

/**
 * A common interface defining methods for start/stop lifecycle control.
 * The typical use case for this is to control asynchronous processing.
 * <b>NOTE: This interface does not imply specific auto-startup semantics.
 * Consider implementing {@link SmartLifecycle} for that purpose.</b>
 *
 * <p>Can be implemented by both components (typically a Spring bean defined in a
 * Spring context) and containers  (typically a Spring {@link ApplicationContext}
 * itself). Containers will propagate start/stop signals to all components that
 * apply within each container, e.g. for a stop/restart scenario at runtime.
 *
 * <p>Can be used for direct invocations or for management operations via JMX.
 * In the latter case, the {@link org.springframework.jmx.export.MBeanExporter}
 * will typically be defined with an
 * {@link org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler},
 * restricting the visibility of activity-controlled components to the Lifecycle
 * interface.
 *
 * <p>Note that the present {@code Lifecycle} interface is only supported on
 * <b>top-level singleton beans</b>. On any other component, the {@code Lifecycle}
 * interface will remain undetected and hence ignored. Also, note that the extended
 * {@link SmartLifecycle} interface provides sophisticated integration with the
 * application context's startup and shutdown phases.
 *
 * @author Juergen Hoeller
 * @since 2.0
 * @see SmartLifecycle
 * @see ConfigurableApplicationContext
 * @see org.springframework.jms.listener.AbstractMessageListenerContainer
 * @see org.springframework.scheduling.quartz.SchedulerFactoryBean
 */
/**
 *定义启动/停止生命周期控制方法的通用接口。
 *这方面的典型用例是控制异步处理。
 *＜b＞注意：这个接口并不意味着特定的自动启动语义。
 *考虑为此目的实施｛@link SmartLifecycle｝</b>
 *
 *＜p＞可以由两个组件实现（通常是在
 *Spring上下文）和容器（通常是Spring｛@link ApplicationContext｝
 *本身）。容器将向所有组件传播启动/停止信号
 *在每个容器中应用，例如用于运行时的停止/重新启动场景。
 *
 *＜p＞可以用于直接调用或通过JMX进行管理操作。
 *在后一种情况下，{@linkorg.springframework.jmx.export.MBeanExporter}
 *通常用
 *｛@link org.springframework.jmx.export.assembly.InterfaceBasedMBeanInfoAssembler｝，
 *限制活动控制组件在生命周期中的可见性
 *接口。
 *
 *<p>请注意，当前的｛@code Lifecycle｝接口仅在上受支持
 *＜b＞顶级单例bean＜/b＞。在任何其他组件上，｛@code Lifecycle｝
 *接口将保持未被检测，因此被忽略。此外，请注意
 *｛@link SmartLifecycle｝接口提供了与
 *应用程序上下文的启动和关闭阶段。
 *
 *@作者Juergen Hoeller
 *@自2.0起
 *@请参阅SmartLifecycle
 *@请参阅可配置的应用程序上下文
 *@参见org.springframework.jms.listener.AbstractMessageListenerContainer
 *@参见org.springframework.scheduling.quartz.SchedulerFactoryBean
 */
public interface Lifecycle {

	/**
	 * Start this component.
	 * <p>Should not throw an exception if the component is already running.
	 * <p>In the case of a container, this will propagate the start signal to all
	 * components that apply.
	 * @see SmartLifecycle#isAutoStartup()
	 */
	/**
	 *启动此组件。
	 *＜p＞如果组件已经在运行，则不应引发异常。
	 *<p>在容器的情况下，这将把启动信号传播到所有
	 *应用的组件。
	 *@请参阅SmartLifecycle#isAutoStartup（）
	 */
	void start();

	/**
	 * Stop this component, typically in a synchronous fashion, such that the component is
	 * fully stopped upon return of this method. Consider implementing {@link SmartLifecycle}
	 * and its {@code stop(Runnable)} variant when asynchronous stop behavior is necessary.
	 * <p>Note that this stop notification is not guaranteed to come before destruction:
	 * On regular shutdown, {@code Lifecycle} beans will first receive a stop notification
	 * before the general destruction callbacks are being propagated; however, on hot
	 * refresh during a context's lifetime or on aborted refresh attempts, a given bean's
	 * destroy method will be called without any consideration of stop signals upfront.
	 * <p>Should not throw an exception if the component is not running (not started yet).
	 * <p>In the case of a container, this will propagate the stop signal to all components
	 * that apply.
	 * @see SmartLifecycle#stop(Runnable)
	 * @see org.springframework.beans.factory.DisposableBean#destroy()
	 */
	/**
	 *通常以同步方式停止此组件，以便组件
	 *此方法返回时完全停止。考虑实施｛@link SmartLifecycle｝
	 *以及在需要异步停止行为时的{@code-stop（Runnable）}变体。
	 *<p>请注意，此停止通知不能保证在销毁之前发出：
	 *在定期关闭时，｛@code Lifecycle｝bean将首先收到停止通知
	 *在传播一般销毁回调之前；然而，在热的时候
	 *在上下文的生存期内或在中止的刷新尝试时刷新，给定的bean
	 *destroy方法将被调用，而不需要预先考虑任何停止信号。
	 *＜p＞如果组件未运行（尚未启动），则不应引发异常。
	 *<p>在容器的情况下，这将把停止信号传播到所有组件
	 *适用。
	 *@请参阅SmartLifecycle#stop（可运行）
	 *@见org.springframework.beans.factory.DisposableBean#destroy（）
	 */
	void stop();

	/**
	 * Check whether this component is currently running.
	 * <p>In the case of a container, this will return {@code true} only if <i>all</i>
	 * components that apply are currently running.
	 * @return whether the component is currently running
	 */
	/**
	 *检查此组件当前是否正在运行。
	 *＜p＞在容器的情况下，只有当＜i＞所有＜i＞时，才会返回｛@code true｝
	 *应用的组件当前正在运行。
	 *@return组件当前是否正在运行
	 */
	boolean isRunning();

}
